<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引用vue3的源码 -->
    <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
    <div class="app"></div>
   
</body>
<script>
    //声明一个变量对进行接收
   const app = Vue.createApp({
        data() {
            return {
                list:[],
                inputValue:""
            }
        },
        methods: {
            handleAddItem(){
                this.list.push(this.inputValue)
                this.inputValue=''
            }
        },
        template:`
        <div>
            <name />
            <input v-model="inputValue">
            <button v-on:click="handleAddItem">增加佳丽</button>
            <ul>
                <jiali
                    v-for="(item,index) of list"
                    v-bind:item="item"
                    v-bind:index="index"
                />
            </ul>
            </div>
        `
    })

    //先声明一个单独的组件
    app.component('name',{
        //创建模板
        template:'<h1 style="text-align: center;">象牙山洗脚城</h1>'
    })

    app.component('jiali',{
        //接收父组件传来的参数
        props:['index','item'],
        template:`
            <li>[{{index}}]-{{item}}</li>
        `
    })

    //再绑定容器进行使用
    app.mount(".app")
</script>
</html>